package com.shell.governor.modules.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.shell.bee.base.utils.StringUtil;
import com.shell.bee.persistence.service.impl.PersistentServiceImpl;
import com.shell.governor.modules.dao.PubProtocolFinDao;
import com.shell.governor.modules.po.PubProtocolFin;
import com.shell.governor.modules.service.PubProtocolFinService;

@Service
public class PubProtocolFinServiceImpl extends PersistentServiceImpl<PubProtocolFin> implements PubProtocolFinService {
	@Autowired
	private PubProtocolFinDao pubProtocolFinDao;

	public int clearAndSave(String protoId, String finIds) {
		this.pubProtocolFinDao.deleteByProtoId(protoId);
		if (!StringUtil.emptyAndNull(finIds)) {
			String[] idArr = finIds.split(",");
			for (String finId : idArr) {
				PubProtocolFin ppf = new PubProtocolFin();
				ppf.setFinId(finId);
				ppf.setProtoId(protoId);
				save(ppf);
			}
		}
		return 0;
	}

	public List<String> selectFinIdsByProtoId(String protoId) {
		return this.pubProtocolFinDao.selectFinIdsByProtoId(protoId);
	}
}
